package com.pan.creational.builder.entity;

public class Person {

    private Body body;
    private Head head;
    private Hand hand;
    private Leg leg;

    public Person() {
    }


    public void live(){
        try {
            head.useHead();
            body.useBody();
        }catch (NullPointerException e){
            System.out.println("是个死人");
            return;
        }

        if (hand==null) {
            System.out.println("没有手");
        } else {
            hand.useHand();
        }
        if (leg==null) {
            System.out.println("没有腿");
        }else {
            leg.useLeg();
        }
    }


    public void setBody(Body body) {
        this.body = body;
    }

    public void setHead(Head head) {
        this.head = head;
    }

    public void setHand(Hand hand) {
        this.hand = hand;
    }

    public void setLeg(Leg leg) {
        this.leg = leg;
    }
}
